﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript">
       
        var ocxObject;
        function pageLoad() {
            ocxObject = document.getElementById("OcxObject");
            ocxObject.SetOcxMode(0);
        }

        function startPreview() {
            var previewXml = buildPreviewXml();
            var ret = ocxObject.StartTask_Preview_InWnd(previewXml, 0);
            if (ret == 0) {
            } else {
                alert("startPreview fail >>> " + ret)
            }
        }
        //
        function startTaskptz()
        {
            var ret = ocxObject.StartTask_PTZ(23, 0)

            if (ret == 0) {
                //alert("sfd");
            } else {
                alert("StartTask_PTZ fail >>> " + ret)
            }
        }
        //
        function PTZCtrlSet()
        {
            var ret = ocxObject.PTZCtrlSetPreset(165);

            if (ret == 0) {
                //alert("sfd");
            } else {
                alert("PTZCtrlSetPreset fail >>> " + ret)
            }
        }

        function PTZCtrlGOTO()
        {
            var ret = ocxObject.PTZCtrlGotoPreset(165);

            if (ret == 0) {
                //alert("sfd");
            } else {
                alert("PTZCtrlGotoPreset fail >>> " + ret)
            }
        }

        function buildPreviewXml() {
            //该XML可以自己写，也可以通过WebService获取预览所需的参数接口获取
            //return "<?xml version='1.0' encoding='UTF-8'?>"+
            //    "<Message><Camera>"+
            //    "<Id>1</Id>"+
            //    "<IndexCode>2015121711310018856</IndexCode>" +
            //    "<Name>IPdome</Name>" +
            //    "<ChanNo>0</ChanNo>" +
            //    "<Matrix Code='0' Id='0' /></Camera>" +
            //    "<Dev regtype='4' devtype='0'>" +
            //    "<Id>2</Id>" +
            //    "<IndexCode>201512171</IndexCode>" +
            //    "<Addr IP='223.99.163.178' Port='7302' />" +
            //    //"<Auth User='admin' Pwd='hik12345+'/>" +
            //    "</Dev>" +
            //    "<Vag IP='223.99.163.178' Port='7300' />" +
            //    "<Voice><Encode>1</Encode></Voice>" +
            //    "<User><Name>admin</Name><IP>223.99.163.179</IP></User>" +
            //    "<Media Protocol='0' Stream='0'>" + 
            //    "<Vtdu IP='223.99.163.178' Port='6010' /></Media>" +
            //    "<Privilege Priority='50' Code='3' />" +
            //    "<Option><Talk>1</Talk><PreviewType>1</PreviewType></Option></Message>";

            var xmlstr = "<?xml version='1.0' encoding='UTF-8'?>" +
          "<Message>" +
          "<Camera>" +
          "<Id>1</Id>" +
          "<IndexCode>2015121711310018856</IndexCode>" +
          "<Name>IP DOME</Name>" +
          "<ChanNo>0</ChanNo>" +
          "<Matrix Code=0 Id=0 />" +
          "</Camera>" +
          "<Dev regtype=0 devtype=1>" +
          "<Id>1</Id>" +
          "<IndexCode>201512171</IndexCode>" +
          "<Addr IP='223.99.163.178' Port='7302' />" +
          "<Auth User='admin' Pwd='hik12345+' />" +
          "</Dev>" +
          "<Vag IP='223.99.163.178' Port='7302' />" +
          //"<Voice><Encode>1</Encode></Voice>" +
          //"<User>" +
          //"<Name>admin</Name>" +
          //"<IP>223.99.163.178</IP>" +
          //"</User>" +
          //"<Media Protocol='0' Stream='0'><Vtdu IP='223.99.163.178' Port='554' /></Media>" +
          "<Privilege Priority=1 Code=15 />" +
          //"<Option><Talk>1</Talk><PreviewType>0</PreviewType></Option>" +
          "</Message>";

            return xmlstr;
        }

       
	</script>
</head>
<body onLoad="pageLoad();">
	<div>
		<object classid="clsid:D5E14042-7BF6-4E24-8B01-2F453E8154D7" id="OcxObject" width="600" height="400" name="OcxObject"></object>
	</div>
	<div id = "preview">
		<input type="button" name="0" value="预览" onclick="startPreview();">
        <input type="button" name="1" value="上迎" onclick="startTaskptz();">
		<input type="button" name="2" value="设置云台预览位" onclick="PTZCtrlSet();">
		<input type="button" name="3" value="调用云台预览位" onclick="PTZCtrlGOTO();">

	</div>
</body>
</html>
